/*
	This file is part of "Ants on the web".

    "Ants on the web" is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    "Ants on the web" is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with "Ants on the web".  If not, see <http://www.gnu.org/licenses/>.
*/

package org.utc.ia04.antsontheweb.gui.request.actionListener;

import jade.gui.GuiEvent;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.utc.ia04.antsontheweb.gui.request.AgentInterfaceRequest;
import org.utc.ia04.antsontheweb.gui.request.InterfaceRequest;

public class CreateAntColonyActionListener implements ActionListener
{
	InterfaceRequest myFrame;
	public CreateAntColonyActionListener(InterfaceRequest _myFrame) { myFrame = _myFrame; }
	
	public void actionPerformed(ActionEvent evt)
	{
		try
		{
			Object [] argsAC = new Object[7];
			argsAC[0] = myFrame.getNbFourmis();
			argsAC[1] = myFrame.getNbCollectedRes();
			argsAC[2] = myFrame.getTick();
			argsAC[3] = myFrame.getWebsiteType();
			argsAC[4] = myFrame.getStartURL();
			argsAC[5] = myFrame.getLifeExtancy();
			argsAC[6] = myFrame.getLifeExtancyVar();
			
			GuiEvent ev = new GuiEvent(myFrame.getMyAgent(), AgentInterfaceRequest.CREATE_AGENT);
			ev.addParameter("AntColony_");
			ev.addParameter("org.utc.ia04.antsontheweb.antColonyOptimisation.antColony.AntColonyAgent");
			ev.addParameter(argsAC);
			
			myFrame.toggleButton();
			myFrame.getMyAgent().postGuiEvent(ev);
		}
		catch(Exception e)
		{
			System.out.println("Error getting arguments... : " + e.toString());
		}	
	}
}
